﻿using GN.Pay.TradeChannel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace GN.Pay.Core.Values.Channel
{
    /// <summary>
    /// 
    /// </summary>
    public class TradeRefundApplyResultValue : ITradeRefundApplyResult
    {
        public string ChannelId { get; set; }

        public string ChannelName { get; set; }

        public decimal RefundFee { get; set; }

        public decimal RefundMoney { get; set; }

        public string RefundNo { get; set; }

        public DateTime? RefundTime { get; set; }

        public TradeApplyResultState ResultState { get; set; }

        public string ResultStateMessage { get; set; }

        public string TradeNo { get; set; }

        /// <summary>
        /// 
        /// </summary>
        public void Validation()
        {
            if (string.IsNullOrWhiteSpace(this.ChannelId))
            {
                this.ThrowChannelValidationException
                   ("TradeNo 为 null 或空白");
            }
            if (this.RefundFee < 0)
            {
                this.ThrowChannelValidationException
                    ("RefundFee 小于零");
            }
            if (this.RefundMoney <= 0)
            {
                this.ThrowChannelValidationException
                    ("RefundMoney 小于或等于零");
            }
            if (string.IsNullOrWhiteSpace(this.RefundNo))
            {
                this.ThrowChannelValidationException
                    ("RefundNo 为 null 或空白");
            }
            if (string.IsNullOrWhiteSpace(this.TradeNo))
            {
                this.ThrowChannelValidationException
                    ("TradeNo 为 null 或空白");
            }
        }
    }
}
